<!DOCTYPE HTML>
<html>
<head>
	<title>微信公共平台开发者接口</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="Content-Type"content="text/html;charset=utf-8">
	<meta http-equiv="expires" content="0">
</head>

<body>
	<h1>微信公共平台开发者接口</h1>
		<video id="video" style="width:100%;height:900px;" autoplay></video>
		<br/>
		<button id="snap" style="float:right;"><h1>Snap Photo</h1></button>
		<!-- <canvas id="canvas" width="640" height="480"></canvas> -->
		
		<script type="text/javascript">
			// Put event listeners into place
			window.addEventListener("DOMContentLoaded", function() {
			// Grab elements, create settings, etc.
			//var canvas = document.getElementById("canvas"),
			//context = canvas.getContext("2d"),
			video = document.getElementById("video"),
			videoObj = { "video": true },
			errBack = function(error) {
			console.log("Video capture error: ", error.code); 
			};
			// Put video listeners into place
			if(navigator.getUserMedia) { // Standard
			navigator.getUserMedia(videoObj, function(stream) {
			video.src = stream;
			video.play();
			}, errBack);
			} else if(navigator.webkitGetUserMedia) { // WebKit-prefixed
			navigator.webkitGetUserMedia(videoObj, function(stream){
			video.src = window.webkitURL.createObjectURL(stream);
			video.play();
			}, errBack);
			}
			else if(navigator.mozGetUserMedia) { // Firefox-prefixed
			navigator.mozGetUserMedia(videoObj, function(stream){
			video.src = window.URL.createObjectURL(stream);
			video.play();
			}, errBack);
			}
			}, false);
			
			// 触发拍照动作
			document.getElementById("snap")
			.addEventListener("click", function() {
			//context.drawImage(video, 0, 0, 640, 480);
			});
		</script>
</body>
</html>
